package com.sservice.base;

import java.math.BigDecimal;

/**
 * Created by suweiming on 2017/12/20.
 */

public class ArrayUtils extends org.apache.commons.lang3.ArrayUtils{
    /**
     * string 数组转换为 double 数组
     * @param strs
     * @return
     */
    public static double[] strToInt(String[] strs){
        double[] in = new double[strs.length];
        for(int i = 0;i<strs.length;i++){
            in[i] = Double.valueOf(strs[i]);
        }
        return in;
    }

    /***
     * 计算数组元素和
     * @param strs
     * @return
     */
    public static BigDecimal strArrayTotal(String[] strs){
        BigDecimal total = BigDecimal.valueOf(0.0);
        for(int i = 0;i<strs.length;i++){
            total = total.add(BigDecimal.valueOf(Double.valueOf(strs[i])));
        }
        return total;
    }
}
